<?php
	//Open gadget, do __MODULE_ID__ replacements
	$gadgetsDir = "gadgets/";
	$langDir = $gadgetsDir."lang/";
	
		$gadgetFileName = @$_GET['gadget'];

	
		if ((!isset($gadgetFileName)) || ($gadgetFileName == ""))
		{
			$gadgetFileName = "helloWorld.xml";
		}
	
	$fh = fopen($gadgetsDir.$gadgetFileName, 'r') or die("Can't open gadget file - did you specify a gadget via the query string? E.g. http://localhost/IGLocal/ig.php?gadget=myGadget.xml");
	$contents = fread($fh, filesize($gadgetsDir.$gadgetFileName));
	fclose($fh);
	$gadget = simplexml_load_string(str_replace("__MODULE_ID__", "0", $contents));


	//Override default UP value with one specified in query string
	@$qValue = $_GET["up_title"];
	if ((isset($qValue)) && ($qValue != ""))
	{
		$gadgetTitle = $qValue;
	}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>IGLocal :: iGoogle Local Development Kit by Bonstio</title>
    <script>var _IG_time_epoch = (new Date()).getTime();</script>
    <script src="js/ig.js"></script>
    <script src="js/libminimessage.js"></script>
	<script src="js/IGLocal.js"></script>
    <script>var domain = document.location.hostname;

    _source = "";
    _uli = true;
    _pnlo = false;
    _mpnlo = false;
    _pl = false;
    _mod = true;
    _pid = "";
    _old_html = false;
    _use_old_feed_styles = false;
    _cbp = true;
    _is_dasher = false;
    _upc();
    </script>
    <script><!--
    function save_chkbox_value(hidden_elem_name, checked)
    {
        var hidden_elem = document.getElementById(hidden_elem_name);
        hidden_elem.value = checked ? "1" : "0";
    }
    function RemoteModule(spec_url, id, render_inline, base_iframe_url, caching_disabled)
    {
        this.spec_url = spec_url;
        this.id = id;
        this.render_inline = render_inline;
        this.base_iframe_url = base_iframe_url;
        this.caching_disabled = caching_disabled;
        this.old_width = 0;
        this.wants_scaling = false;
        this.is_inlined = function()
        {
            return this.base_iframe_url == "";
        };
    }
    ;
    var remote_modules = [];

    function ifpc_resizeIframe(iframe_id, height)
    {
        var el = document.getElementById(iframe_id);
        if (el)
        {
            el.style.height = height + "px";
        }
    }
    _IFPC.registerService('resize_iframe', ifpc_resizeIframe);
    function _ig_gmid_(iframe_id)
    {
        return(iframe_id.split("_")[2]);
    }
    function _setModTitle(title, module_id)
    {
        var title_element = _gel("m_" + module_id + "_title");
        if (title_element)
        {
            title_element.innerHTML = _hesc(title);
        }
    }
    function ifpc_setTitle(iframe_id, title)
    {
        if (typeof(iframe_id) == undefined || !iframe_id || iframe_id == "undefined")
        {
            return;
        }
        _setModTitle(title, _ig_gmid_(iframe_id));
    }
    _IFPC.registerService('set_title', ifpc_setTitle);
    function _IG_SetTitle(title, specified_module_id)
    {
        if (typeof(specified_module_id) == "undefined" || !specified_module_id || specified_module_id == "undefined")
        {
            throw new Error("Inline modules must specify their " + "__MODULE_ID__ when using _IG_SetTitle");
        }
        else
        {
            _setModTitle(title, specified_module_id);
        }
    }
    function ifpc_setPref(iframe_id, var_args)
    {
        var module_id = _ig_gmid_(iframe_id);
        var prefs = new _IG_Prefs(module_id);
        var keyValues = new Array();
        for (var n = 1; n < arguments.length; n += 2)
        {
            keyValues.push(arguments[n], arguments[n + 1]);
        }
        prefs.set.apply(prefs, keyValues);
    }
    _IFPC.registerService('set_pref', ifpc_setPref);
    // -->
    </script>
    <link rel="stylesheet" type="text/css" href="css/ig.css"/>
    <style>
    </style>
</head>
<body>
<script>
<?php

				/**
				Init User Prefs default values
				**/

				foreach ($gadget->UserPref as $up)
				{
					$name = ((string)$up['name']);
					$value = $up['default_value'];

					//Override default UP value with one specified in query string
					@$qValue = $_GET["up_" . $name];
					if ((isset($qValue)) && ($qValue != ""))
					{
						$value = $qValue;
					}

					echo "\t__UP_" . $name . "__ = ";

					switch((string) $up['datatype'])
					{
						// Get attributes as element indices
						case 'list':
							echo "[";
							
							$list = split("\|", $value);
							for ($i = 0; $i < count($list); $i++)
							{
								echo "'" . $list[$i] . "'";
								if ($i+1 < count($list))
								{
									echo ",";
								}
								else
								{
									echo "]";
								}
							}
							
							break;
						
						case 'bool':
							echo $value;

							break;

						case 'enum':
						case 'hidden':
						default:
							echo "'" . $value . "'";
					}

					echo ";\r\n";
				}

			?>


			function _IG_RegisterOnloadHandler(onloadFunction)
			{
				if (onloadFunction) window.onload = onloadFunction;
			}

			function _IG_Analytics(id, path)
			{
				//TODO alphanumeric checking here
			}

			function _gel(id)
			{
				return document.getElementById(id);
			}

			function _IG_Prefs(id)
			{
				_IG_Prefs.prototype.set = function(name, value) 
				{
					eval("__UP_" + name + "__ = '" + value + "'");		
				};

				_IG_Prefs.prototype.getBool = function(name) 
				{
					return eval("__UP_" + name + "__");
				};

				_IG_Prefs.prototype.getInt = function(name) 
				{
					return parseInt(eval("__UP_" + name + "__"));
				};

				_IG_Prefs.prototype.getString = function(name) 
				{
					return eval("__UP_" + name + "__");	
				};

				_IG_Prefs.prototype.getArray = function(name) 
				{
					return eval("__UP_" + name + "__");	
				};
			}

		function ifpc_resizeIframe(iframe_id, height)
		{
			var el = document.getElementById(iframe_id);
			if (el)
			{
				el.style.height = height + "px";
			}
		}

		function _IG_AdjustIFrameHeight()
		{

		}

	</script>

	<div id="doc3">
	<div id="nhdrwrap">
		<div id="nhdrwrapinner">
			<div id="nhdrwrapsizer">
				<div id="gsea">
					<form id="sfrm" name="f" method="get" action="http://www.google.com/search">
						<table cellpadding="0" cellspacing="0">
							<tr>
								<td valign="top" class="gsealog">
									<div id="regular_logo">&nbsp;</div>
								</td>
								<td align="center" class="gseain" valign="top" nowrap>
									<input type="hidden" name="source" value="ig"><input type="hidden" name="hl" id="hl" value="en">

									<div id="featuretabs">
										<style>#lgpd {
											display: none
										}</style>
										<script defer><!--
										function qs(el)
										{
											if (window.RegExp && window.encodeURIComponent)
											{
												var ue = el.href,qe = encodeURIComponent(document.f.q.value);
												if (ue.indexOf("q=") != -1)
												{
													el.href = ue.replace(new RegExp("q=[^&$]*"), "q=" + qe);
												}
												else
												{
													el.href = ue + "&q=" + qe;
												}
											}
											return 1;
										}
										//-->
										</script>
										<table border=0 cellspacing=0 cellpadding=4>
											<tr>
												<td nowrap>
													<font size=-1><b>Web</b>&nbsp;&nbsp;&nbsp;&nbsp;<a class=q href="http://images.google.co.uk/imghp?tab=wi" onclick="return qs(this)">Images</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class=q href="http://news.google.co.uk/nwshp?tab=wn" onclick="return qs(this)">News</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class=q href="http://maps.google.co.uk/maps?tab=wl" onclick="return qs(this)">Maps</a><span style="position:relative;color:red;top:-5px;">New!</span>&nbsp;&nbsp;&nbsp;&nbsp;<a class=q href="http://www.google.co.uk/prdhp?tab=wf" onclick="return qs(this)">Products</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class=q href="http://groups.google.co.uk/grphp?tab=wg" onclick="return qs(this)">Groups</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class=q href="http://scholar.google.com/schhp?tab=ws" onclick="return qs(this)">Scholar</a>&nbsp;&nbsp;&nbsp;&nbsp;<!--"/*"/*--><font size=-1><a class=q onClick='return window.qs?qs(this):1' href='http://127.0.0.1:4664/&s=MWUyAScw9Xbmpj-ydNaR2enYnnw'>Desktop</a></font>&nbsp;&nbsp;&nbsp;&nbsp;<b><a href="http://www.google.com/intl/en/options/" class=q>more&nbsp;&raquo;</a></b></font>
												</td>
											</tr>
										</table>
									</div>
									<input type="text" name="q" id="q" size="55" maxlength="2048" value=""><br><input type="submit" value="Google Search" name="btnG" id="btnG"><input type="submit" value="I'm Feeling Lucky" name="btnI" id="btnI"><br>
								</td>
								<td valign="top"><br>

									<p class="gseaopt">
										<a href="http://www.google.com/advanced_search?hl=en">Advanced Search</a><br><a href="http://www.google.com/preferences?hl=en">Preferences</a><br><a href="http://www.google.com/language_tools?hl=en">Language Tools</a>
									</p></td>
							</tr>
						</table>
					</form>
				</div>
				<script>_gel('sfrm').onsubmit = function()
				{
					_log('search');
					return true;
				}</script>
				<script>function qs(el)
				{
					if (window.RegExp && window.encodeURIComponent)
					{
						var qe = encodeURIComponent(document.f.q.value);
						if (el.href.indexOf("q=") != -1)
						{
							el.href = el.href.replace(new RegExp("q=[^&$]*"), "q=" + qe);
						}
						else
						{
							el.href += "&q=" + qe;
						}
					}
					return 1;
				}
				if (document.all)
				{
					_IG_AddDOMEventHandler(window, "focus", function()
					{
						_gel("q").focus();
						_IG_RemoveDOMEventHandler(window, "focus", arguments.callee);
					});
				}
				else
				{
					_gel("q").focus();
				}</script>
				<div id="undel_msg" class="msg" style="display:none;">
					<div id="undel_box" class="msg_box"><span id="undel_title"></span> has been removed.
						<a href="javascript:void(_undel())">Undo</a> |
						<a href="#" class="delbox_u" onclick="_gel('undel_msg').style.display='none';return false;">Close</a>
					</div>
				</div>
				<noscript>
					<div id="noscript_msg" class="msg">
						<div id="noscript_box" class="msg_box">You need to have JavaScript enabled to use this page.</div>
					</div>
				</noscript>
				<script>_IG_time.stop("parse_header");</script>
				<div id="new_user_demo" align="center"></div>
				<!-- Copyright 2007 and beyond, Google Inc.  To use gadgets on your own site, visit http://www.google.com/webmasters/gadgets.  To create your own gadgets, visit http://www.google.com/apis/gadgets -->
			</div>
			<div id="tabs">
				<ul>

					<li id="tab8_edit" class="tab edittab selectedtab" style="display:none"  onmouseover="_disable_onblur=true;" onmouseout="_disable_onblur=false;"></li>
					<li id="tab8_view" class="tab selectedtab" style="display:block" title="Click to rename or delete.">
						<span id="tab8_view_title" style="float:left;">IGLocal</span>
					</li>

					<li class="tab selectedtab_r">&nbsp;</li>
					<li class="tab addtab">&nbsp;&nbsp;
						<script src="http://www.google.com/ig/ig_popup.js"></script>
						<script>function _mtabs_send()
						{
							var url = "http://www.google.com/ig/filltab?et=9S9CvQOT&igtab=";
							url += _esc(_gel("mtab").value);
							url += "&filltab=";
							if (_gel("mfill").checked)
							{
								url += "1";
							}
							else
							{
								url += "0";
							}
							url += "&url=" + _esc(document.location);
							document.location = url;
							return false;
						}
						function _replace_div(name)
						{
							var oldDiv = _gel(name);
							var newDiv = _gel("replace");
							if (!newDiv)
							{
								newDiv = document.createElement("div");
								newDiv.id = "replace";
								newDiv.style.display = "none";
								oldDiv.parentNode.appendChild(newDiv);
							}
							newDiv.style.width = "" + oldDiv.clientWidth + "px";
							newDiv.style.height = "" + Math.max(oldDiv.offsetHeight, oldDiv.scrollHeight) + "px";
							newDiv.style.backgroundColor = "#fff";
							_toggle(oldDiv);
							_toggle(newDiv);
						}
						function _close_mtabs_dialog()
						{
							_toggle(_gel("replace"));
							_toggle(_gel("modules"));
							return true;
						}
						function _open_mtabs_dialog()
						{
							_replace_div("modules");
							var titleHtml = "\x3ctable id\x3d\"mtabs_title\" width\x3d\"100%\"\x3e\x3ctr\x3e\x3ctd\x3e\x3cstrong\x3eAdd a tab\x3c/strong\x3e\x3c/td\x3e\x3ctd align\x3d\"right\"\x3e\x3cinput type\x3d\"image\" src\x3d\"http://www.google.com/ig/images/x_blue.gif\" onclick\x3d\"_close_mtabs_dialog(); _CloseDialog(2); return true;\" /\x3e\x3c/td\x3e\x3c/tr\x3e\x3c/table\x3e";
							var bodyHtml = "\x3ctable id\x3d\"mtabs_body\"\x3e\x3ctr\x3e\x3ctd style\x3d\"white-space:nowrap\"\x3e\x3cfont size\x3d\"-1\"\x3eTab name:\x3c/font\x3e\x3c/td\x3e\x3ctd\x3e\x3cform onsubmit\x3d\"_mtabs_send(); return false;\"\x3e\x3cfont size\x3d\"-1\"\x3e\x3cinput id\x3d\"mtab\" type\x3d\"text\" name\x3d\"tab\" size\x3d\"40\" /\x3e\x3c/font\x3e\x3c/form\x3e\x3c/td\x3e\x3c/tr\x3e\x3ctr\x3e\x3ctd\x3e\x3cfont size\x3d\"-1\"\x3e\x3c/font\x3e\x3c/td\x3e\x3ctd\x3e\x3cfont size\x3d\"-2\" color\x3d\"#676767\"\x3ee.g. News, Finance, Sports\x3c/font\x3e\x3c/td\x3e\x3c/tr\x3e\x3ctr\x3e\x3ctd colspan\x3d\"2\"\x3e\x26nbsp;\x3c/td\x3e\x3c/tr\x3e\x3ctr\x3e\x3ctd colspan\x3d\"2\"\x3e\x3cfont size\x3d\"-1\"\x3e\x3cinput name\x3d\"fill\" id\x3d\"mfill\" type\x3d\"checkbox\" checked /\x3e\x3clabel for\x3d\"mfill\"\x3eI\x26#39;m feeling lucky. Automatically add stuff based on the tab name.\x3c/label\x3e\x3c/font\x3e\x3c/td\x3e\x3c/tr\x3e\x3c/table\x3e";
							var buttonsHtml = ["<input type=\"button\" onclick=\"return _mtabs_send();\""
									+ " style=\"font-weight:bold; width:100px\" value=\"OK\" />","<input type=\"button\" onclick=\"return _close_mtabs_dialog();\""
									+ " style=\"width:100px\" value=\"Cancel\" />"];
							_Confirm(null, titleHtml, bodyHtml, buttonsHtml);
							_IG_RegisterOnloadHandler(function()
							{
								_gel("mtab").focus();
							});
							return false;
						}</script>
						
					<li class="tab" id="addstuff">
						
					</li>
				</ul>
			</div>
		</div>
	</div>
	<div id="modules">
	<div class="yui-b">
	<div class="yui-gb" id="t_1">
	<div class="yui-u first" id="c_1">
		<div class="dm"></div>
	</div>
	<div class="yui-u" id="c_2">

	<?php require("gadget.php"); ?>

	<div class="dm"></div>
	</div>
	<div class="yui-u" id="c_3">
		<div class="dm"></div>
	</div>
	<div class="dm c">&nbsp;</div>
	</div>
	</div>
	</div>
	</div>

	<div id="footerwrap">
	<div id="footerwrapinner"><p id="footer_promos">
			iGoogle Local Development Kit - 
				<a href="http://bonstio.net">by Bonstio</a> (with a bit of help from <a href="http://www.google.com">Google</a>).
				<br>
				<br>
				<a href="http://www.google.com/ig/">iGoogle</a> -
				<a href="http://www.google.com/apis/gadgets/docs-home.html">Google Gadgets API - Documentation Home</a> - 
				<a href="http://www.google.com/intl/en/help/privacy_fusionph.html">Privacy Policy</a> -
				<a href="http://www.google.com/apis/gadgets/reference.html">API Reference</a> -
				<a href="http://www.google.com/apis/gadgets/gs.html#Scratchpad">Google Gadget Scratchpad</a><br><br>
				<a href="http://www.google.com/intl/en/help/privacy_fusionph.html">Privacy Policy</a> -
				<span class="copyr">&copy;2007 Google</span></p>
		</div>
	</div>
	<script>_table = _gel("t_1");
	_tabs = _gel("tabs");
	_pl = true;
	_IG_time.stop("upcstart");
	_upc();
	_IG_time.stop("upcend");
	_IG_start_refresh_cycle(1200, 600);
	_IG_time.stop("domloadstart");
	_IG_AddEventHandler("domload", function()
	{
		_IG_time.stop("domloadend");
	});
	_IG_TriggerDelayedEvent("domload");
	</script>
</body>
</html>











































